<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>
        <h1 class="pull-right">
            <?php echo $this->HelpUrl('salesService'); ?>
        </h1>
    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                    <div class="box shop-box">
                        <div class="box-body table-responsive no-padding">
                            <table class="table shop-table table-hover">
                                <thead>
                                <tr class="shop-bg-thead">
                                    <th width="26%"><?php echo $this->translate('商品名称'); ?></th>
                                    <th width="10%"><?php echo $this->translate('申请人'); ?></th>
                                    <th width="12%"><?php echo $this->translate('申请类型'); ?></th>
                                    <th width="10%"><?php echo $this->translate('状态'); ?></th>
                                    <th width="15%"><?php echo $this->translate('申请时间'); ?></th>
                                    <th width="15%"><?php echo $this->translate('处理时间'); ?></th>
                                    <th width="12%"><?php echo $this->translate('操作'); ?></th>
                                </tr>
                                <?php
                                $sForm = $this->searchForm;
                                $sForm->prepare();
                                $sForm->get('return_type')->setEmptyOption('选择类型');
                                $sForm->get('return_state')->setEmptyOption('选择状态');
                                ?>
                                <?php echo $this->form()->openTag($sForm); ?>
                                <tr>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('goods_name')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('user_name')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('user_name'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('return_type')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('return_type'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?php echo $this->formElement($sForm->get('return_state')); ?>
                                        <?php echo $this->formElementErrors($sForm->get('return_state'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_add_time')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_add_time')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_add_time'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_add_time'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?php echo $this->formElement($sForm->get('start_review_time')); ?>
                                        </p>
                                        <div>
                                            <?php echo $this->formElement($sForm->get('end_review_time')); ?>
                                        </div>
                                        <?php echo $this->formElementErrors($sForm->get('start_review_time'), ['class'=>'error-message']);?>
                                        <?php echo $this->formElementErrors($sForm->get('end_review_time'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                        <?php
                                        $formData = array_filter($sForm->getData());
                                        if(!empty($formData)) { ?>
                                            &nbsp;&nbsp;<a href="<?php echo $this->url('sales-service');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                        <?php } $formData['page'] = $this->goodsReturnList->getCurrentPageNumber(); ?>
                                    </td>
                                </tr>
                                <?php echo $this->form()->closeTag(); ?>
                                </thead>
                                <tbody>
                                <?php if($this->goodsReturnList->getCurrentItemCount() > 0) foreach ($this->goodsReturnList as $goodsValue) { ?>
                                    <tr>
                                        <td>
                                            <small><?php echo $this->translate('订单编号').'：'.$goodsValue[0]->getOrderSn(); ?></small><br>
                                            <img src="<?php echo $this->goodsHelper()->goodsImage($goodsValue['goodsImage']); ?>" class="img-thumbnail" style="width: 40px;height: 40px;">
                                            <?php echo $this->escapeHtml($goodsValue['goodsName']); ?>
                                        </td>
                                        <td><?php echo $this->escapeHtml($goodsValue[0]->getUserName()); ?></td>
                                        <td><?php echo $this->salesHelper()->getOrderGoodsReturnType($goodsValue[0]->getReturnType()); ?></td>
                                        <td><?php echo $this->salesHelper()->getOrderGoodsReturnState($goodsValue[0]->getReturnState()); ?></td>
                                        <td><?php echo $this->shopDateFormat()->orderGoodsReturnTime($goodsValue[0]->getAddTime()); ?></td>
                                        <td><?php echo $goodsValue[0]->getReviewTime() > 0 ? $this->shopDateFormat()->orderGoodsReturnTime($goodsValue[0]->getReviewTime()) : $this->translate('无'); ?></td>
                                        <td>
                                            <?php if ($goodsValue[0]->getReturnState() > 1) { ?>
                                                <a href="<?php echo $this->url('sales-service',
                                                    ['action'=>'view', 'id'=>$goodsValue[0]->getReturnId()], ['query' => $formData]); ?>"
                                                   class="btn btn-xs btn-success"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看详情'); ?></a>
                                            <?php } else { ?>
                                                <a href="<?php echo $this->url('sales-service',
                                                    ['action'=>'edit', 'id'=>$goodsValue[0]->getReturnId()], ['query' => $formData]); ?>"
                                                   class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('审核'); ?></a>

                                                <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要删除该信息吗?'); ?>', '<?php echo $this->url('sales-service', ['action'=>'delete', 'id'=>$goodsValue[0]->getReturnId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?></a>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                        <div class="box-footer clearfix">
                            <?php echo $this->paginationControl($this->goodsReturnList, 'Sliding', 'layout/page', ['route' => 'sales-service']); ?>
                        </div>
                    </div>
            </div>
        </div>

    </section>
</div>
<script>
    laydate.render({elem: '#start_add_time'});
    laydate.render({elem: '#end_add_time'});

    laydate.render({elem: '#start_review_time'});
    laydate.render({elem: '#end_review_time'});
</script>